package pers.jason.wppm.security.core.validate.code.processor.impl;

import java.io.IOException;

import javax.imageio.ImageIO;

import org.springframework.stereotype.Component;
import org.springframework.web.context.request.ServletWebRequest;

import pers.jason.wppm.security.core.validate.code.ImageCode;

/**
 * 
 * @author Jason
 * @Date 2018-10-39 14:39
 *
 */
@Component
public class ImageValidateCodeProcessor extends AbstractValidateCodeTemplate<ImageCode> {

	@Override
	protected void responseValidateCode(ServletWebRequest request, ImageCode code) throws IOException {
		// TODO Auto-generated method stub
		ImageIO.write(code.getImage(), "JPEG", request.getResponse().getOutputStream());
	}


	@Override
	public String getParamName() {
		return getSecurityProperties().getCode().getImage().getParamName();
	}
}
